font chooser dialog: Improve sensitivity handling
authorMatthias Clasen <mclasen@redhat.com>
Fri, 19 Jan 2018 00:48:12 +0000 (19:48 -0500)
committerMatthias Clasen <mclasen@redhat.com>
Fri, 19 Jan 2018 00:48:12 +0000 (19:48 -0500)
Enable the select button when a font is selected, as it should be.

gtk/gtkfontchooserdialog.c

index ac11ba928469c00b853f9bbe70e84e1f83bd9e01..4805ad374e072df1e9c7db2dd61711122ecccf36 100644 (file)
@@ -159,6 +159,20 @@ gtk_font_chooser_dialog_class_init (GtkFontChooserDialogClass *klass)
   gtk_widget_class_bind_template_callback (widget_class, font_activated_cb);
 }
 
+static void
+update_button (GtkFontChooserDialog *dialog)
+{
+  GtkFontChooserDialogPrivate *priv = dialog->priv;
+  PangoFontDescription *desc;
+
+  desc = gtk_font_chooser_get_font_desc (GTK_FONT_CHOOSER (priv->fontchooser));
+
+  gtk_widget_set_sensitive (priv->select_button, desc != NULL);
+
+  if (desc)
+    pango_font_description_free (desc);
+}
+
 static void
 gtk_font_chooser_dialog_init (GtkFontChooserDialog *fontchooserdiag)
 {
@@ -182,6 +196,10 @@ G_GNUC_END_IGNORE_DEPRECATIONS
 
   _gtk_font_chooser_set_delegate (GTK_FONT_CHOOSER (fontchooserdiag),
                                   GTK_FONT_CHOOSER (priv->fontchooser));
+
+  g_signal_connect_swapped (priv->fontchooser, "notify::font-desc",
+                            G_CALLBACK (update_button), fontchooserdiag);
+  update_button (fontchooserdiag);
 }
 
 /**